package com.celan.year2023.month01.day15;

public class Solution {
    /**
     * leetcode2293
     */
    public int minMaxGame(int[] nums) {
        if (nums.length == 1) return nums[0];

        int n = nums.length;
        int[] newNums = new int[n / 2];
        for (int i = 0; i < n / 2; i++) {
            if (i % 2 == 0) {
                newNums[i] = Math.min(nums[2 * i], nums[2 * i + 1]);
            }
            if (i % 2 != 0) {
                newNums[i] = Math.max(nums[2 * i], nums[2 * i + 1]);
            }
        }
        return minMaxGame(newNums);
    }
}
